function res = SecondBestStep2(xi,pr,pw,w,pai,G)
% Input  : xi   = multiplier for RC
%          pr   = parameters
%          pw   = Pareto weight
%          w    = exp(alpha)
%          pai  = density
%          G    = government expenditure
% Output : res  = residual for RC
tic

c1 = zero(eps,((pw(1))/xi)^(1/pr.gam),eps,eps,@(x) SecondBestStep1(x,xi,pr,pw,w,pai));
SecondBestStep1(c1,xi,pr,pw,w,pai);
load c
load y

res = sum(pai.*y) - G - sum(pai.*c);
fprintf('xi %1.7f, res %1.9f   \n', [xi res] )
